package pers.cj.pdos.utils;

import java.io.IOException;

public class TimeLog {
    private Class clazz;
    private String msg;
    private long time;


    public void begin(Class clazz,String msg){
        this.clazz = clazz;
        this.msg=msg;
        this.time = System.currentTimeMillis();
        Logger.getLogger(clazz).info("-----------------------------------------------------"+msg+"开始----------------------------------------------");
    }

    public void end(){
        Logger.getLogger(clazz).info("-----------------------------------------------------"+msg+"结束,所耗费的时间:"+(System.currentTimeMillis()-time)+"----------------------------------------------");
    }

    private static TimeLog timeLog;
    private TimeLog(){

    }

    public static TimeLog getInstance(){
        if (timeLog != null) {
            return timeLog;
        }
        timeLog = new TimeLog();
        return timeLog;
    }
}
